(in-package "ACL2")

(include-book "io-utilities" :dir :teachpacks)
(include-book "list-utilities" :dir :teachpacks)

(set-state-ok t)



;----------specifications-------------
;get the specification line (first line of text file)
;extract all the relavent infromation to be used in group formation



;; converts a list of strings to a list of rational numbers
(defun strs->rats (strs)
  (if (consp strs)
      (cons (str->rat (car strs)) (strs->rats (cdr strs)))
      nil))
 

(defun getstrings (lines)
  (if (consp lines)
      (cons (chrs->str (car lines)) (getstrings (cdr lines)))
      nil
      )
  )

(defun my-loc-from-file-as-string (str)
  (packets #\Newline (str->chrs str)))

(defun my-loc (file-path state)
  (mv-let (str error state)
          (file->string file-path state)
     (if error
         (mv error state)
         (mv (getstrings (my-loc-from-file-as-string str)) state))))

;gets rid of extra spaces and punctuation between words 
(defun strs-join (glue strs)
  (if(endp strs)
     ""
    (if (endp (cdr strs))
        (car strs)
        (concatenate 'string
                  (car strs)
                  glue
                  (strs-join glue (cdr strs)))
     )))
;gets ride of white space that is in a single string 
(defun trim-stringss (ss)
  (if (endp ss) ss
      (cons 
       (strs-join " " (words (car ss))) 
       (trim-stringss (cdr ss)))))


;gets the five numbers at the begining of the specification line (#teams & weights) 
;packets remainder of string by semi-colon 
(defun input-parse-helper (xs)
  (cons (strs->rats (trim-stringss (take 5 xs)))
         (car (nthcdr 5 xs))))


;packets the string at |  
(defun parse-input (file-path state)
  (mv-let (strs state) (my-loc file-path state)
          (mv (input-parse-helper (getstrings (packets #\| (str->chrs (car strs)))))
              state)))

;gets number of teams user wants to have
(defun get-num-teams (xs)
  (caaar xs)
  )

(defun get-weights  (xs)
  (cdr (caar xs))
  )


;gets all skill 
(defun get-skill-sets (xs)
  (cdr(car xs))
  )

